# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Clement Tsang (xoronth) <cjhtsang@uwaterloo.ca>

pkgname=bottom
pkgver=0.9.6
pkgrel=1
pkgdesc='A graphical process/system monitor'
arch=('loong64' 'x86_64')
url='https://github.com/ClementTsang/bottom'
license=('MIT')
depends=('gcc-libs')
makedepends=('rust')
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('fcbdbbca85215a4276a1e8c79c3fd7fb8471fbae26639521cde96bc2c30128958d520a97312f33fdc13ce19fbd67c14c18cc5a4f2ecd743f390d69c1cbe5c640')
b2sums=('201484c33cb9978776fe089a04b0b231cfaf719c9210f678ba3909f50cd2a078295e3fc1190db4132ca114d66915dce928cfacd57ae882f0e503b31564bb3ad6')

prepare() {
  cd "$pkgname-$pkgver"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname-$pkgver"
  BTM_GENERATE=true cargo build --frozen --release --features deploy
}

check() {
  cd "$pkgname-$pkgver"
  CARGO_HUSKY_DONT_INSTALL_HOOKS=true cargo test --frozen --features deploy
}

package() {
  cd "$pkgname-$pkgver"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" target/release/btm

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" *.md
  cp -vr docs sample_configs "$pkgdir/usr/share/doc/$pkgname"
  rm -f "$pkgdir/usr/share/doc/$pkgname/docs/.gitignore"

  cd target/tmp/bottom

  # man page
  install -vDm644 -t "$pkgdir/usr/share/man/man1" manpage/btm.1

  # completions
  install -Dm644 completion/_btm "$pkgdir/usr/share/zsh/site-functions/_btm"
  install -Dm644 completion/btm.bash "$pkgdir/usr/share/bash-completion/completions/btm"
  install -Dm644 completion/btm.fish "$pkgdir/usr/share/fish/vendor_completions.d/btm.fish"
}

# vim:set ts=2 sw=2 et:
